package JMF;
import javax.media.*;

public class RTPClient implements ControllerListener, Runnable {

	Player p;
	MediaLocator src;

	public static void main(String[] args) {
		
			RTPClient client = new RTPClient();
			Thread t = new Thread(client);
			t.run();
		
	}

	public RTPClient() {
	}
	public void run() {
		try {
			MediaLocator ml = new MediaLocator("rtp://10.11.38.44:49150/audio");
			p = Manager.createRealizedPlayer(ml);
//			p.addControllerListener(this);
			p.addControllerListener(new ControllerAdapter(){
				
				public synchronized void controllerError(ControllerErrorEvent e){
					System.out.println(e);
				}
				
				public synchronized void connectionError(ConnectionErrorEvent evt){
					System.out.println(evt);
				}
				
				public synchronized void controllerUpdate(ControllerEvent evt) {
					if (evt instanceof EndOfMediaEvent) {
						System.exit(0);
					} else {
						System.out.println(evt.toString());
					}
				}
				
			});
			p.start();
		} catch(Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public synchronized void connectionError(ConnectionErrorEvent evt){
		System.out.println(evt);
	}
	
	public synchronized void controllerUpdate(ControllerEvent evt) {
		if (evt instanceof EndOfMediaEvent) {
			System.exit(0);
		} else {
			System.out.println(evt.toString());
		}
	}
}  